
import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
} from 'react-native';
import ChooseSchool from "./chooseSchool";
import MyToolbarSimple from "../../comps/normal/myToolBarSimple";
import ChooseList from "../../comps/list/myChooseProvinceList";
import NetUtil from "../../util/NetWorkUtil";
import UrlUtils from "../../util/UrlCollection";

let url='https://edu.bjzjmy.com:4455/register/cities?cityId=';

export default class ChooseCounty extends React.Component {
    constructor(){
        super();
        this.state={
            loading:'false',
            firstAll:[],
            data:'',
        }
    }

    render() {
        if (this.state.loading==='false'){
            this.getData();
            return(
                <View style={{flex:1}}>
                    <MyToolbarSimple th={this} title="选择区"/>
                    <View style={styles.container}>
                        <Text>loading............</Text>
                    </View>
                </View>
            )
        }else {
            return (
                <View style={{flex:1}}>
                    <MyToolbarSimple th={this} title="选择区"/>
                    <ChooseList
                        comp={ChooseSchool}
                        data={this.state.data}
                        isSchool={false}
                        nav={this.props.navigator}
                        nameId="county"
                        cityId={this.props.cityId}
                        provinceId={this.props.provinceId}
                    />
                </View>
            );
        }
    }

    /**
     * 请求数据
     */
    getData() {
        console.log("provinceId:"+this.props.provinceId);
        console.log("cityId:"+this.props.cityId);
        console.log("countyId:"+this.props.countyId);

        NetUtil.get(UrlUtils.chooseProvince,
            {'cityId':this.props.cityId},
            (responseData)=>{
                //得到数据,刷新组建
                // setData(responseData);
                this.setState({
                    loading:'true',
                    data:responseData
                });
            }
            )
    }
}

const styles=StyleSheet.create({
    container:{
        flex:1,
        justifyContent:'center',
        alignItems:'center',
    },
});